package com.evil.application.pojo.dto.order.data;

import com.evil.common.application.dto.order.data.ControlDataDTO;
import com.evil.common.application.dto.order.data.ControlDataValueDTO;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 订单数据筛选 请求实体
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
public class OrderDataFilterReqDTO {

    /**
     * 筛选控件 id
     */
    @NotNull(message = "筛选控件id不能为空")
    private Long filterControlId;

    /**
     * 筛选控件 code
     */
    private String filterControlCode;

    /**
     * 筛选控制 值
     */
    private List<ControlDataValueDTO> values;

    public OrderDataFilterReqDTO() {
        this.values = new ArrayList<>();
    }

    public OrderDataFilterReqDTO(ControlDataDTO controlDataDTO) {
        this.filterControlId = controlDataDTO.getControlId();
        this.filterControlCode = controlDataDTO.getControlCode();
        this.values = controlDataDTO.getValues();
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        OrderDataFilterReqDTO that = (OrderDataFilterReqDTO) o;
        return Objects.equals(filterControlId, that.filterControlId) &&
                Objects.equals(filterControlCode, that.filterControlCode);
    }

    @Override
    public int hashCode() {
        return Objects.hash(filterControlId, filterControlCode);
    }
}
